package com.test.thread.example03;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolThreadState {

    public static void main(String[] args) throws InterruptedException {

        // 创建一个包含固定线程数的线程池
        ExecutorService executorService = Executors.newFixedThreadPool(2);

        final Thread thread = new Thread(() -> {
            // 任务代码
            System.out.println("线程执行任务");
        });
        executorService.submit(thread);
        Thread.sleep(2000);
        System.out.println(thread.getState());
        // 关闭线程池
        executorService.shutdown();
        System.out.println(thread.getState());
    }
}
